using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;

using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using Tools = Microsoft.Office.Tools;
using Microsoft.SoftwarePlusServices.ReferenceBits.OutlookPlusServices;


///
/// This file contains the main "AddIn" object of the Outlook + Services Reference Bits Package
/// 
/// You can edit this code manually or, if you are using Visual Studio 2005 or later, you can
/// use the Reference Bits Plugin for Visual Studio which provides guidance, code templates and
/// automated tools to help you develop your Software + Services application
///
/// Version 1.0
/// October 2007
/// Licensed under the Microsoft Permissive Licence
/// See www.codeplex.com for more information and support forums
/// 
/// Visit the http://channel9.msdn.com/ReferenceBits WIKI for more information including
/// screencasts, interviews with the authors, and a community of other Software + Services developers
/// 
namespace OUTLOOK_PLUS_SERVICES_ADDIN
{
    /// <summary>
    /// This class represents the addin object.  It handles the startup and initialization
    /// This class is the controller and delegates actual functionality to other classes.
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
    public partial class ThisAddIn
    {
       
        private Implementation impl = new Implementation();

        ///
        /// This method is called when the addin is started.  This is where the functionality of the addin is 
        /// integrated with Outlook.  The key actions that happen in this method registering of events
        /// and the starting of the update timers that will periodically call scheduled tasks
        /// 
        /// If you intend to use the automated tools do not delete the comments of the form /**@#$ ... @#$**/
        /// as they are used for code template substitution
        /// 
        /// </summary>
        /// <param name="sender">A reference to the object that cause the event.</param>
        /// <param name="e"></param>
        /// 
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {

            //
            // Starting here we call into the Implementation object to initialize all of the Outlook
            // components that this AddIn must construct.
            //

            //
            // First, perform any custom setup steps that must come before
            // folders, regions, ribbons, and scheduled tasks are initialized
            //
            impl.InitialSetup(this.Application);

            //
            // Build Folders
            //
            impl.BuildFolders();

            //
            // Build Ribbons
            //
            impl.BuildRibbons();

            //
            // Build Form Regions
            //
            impl.BuildRegions();

            //
            // Build Scheduled Tasks
            //
            impl.BuildScheduledTasks();

            //
            // Build Option Pages
            // Note: Scheduled Tasks must be built first because
            // an IScheduler object is often an argument to the constructor
            // of an Option Page
            //
            impl.BuildOptionPages();

            //
            // Perform any custom final setup take place
            // that should run before the scheduled tasks start to fire
            //
            impl.FinalSetup();

            //
            // and last, but not least, start the scheduled tasks
            //
            impl.StartScheduledTasks();

        }

        ///
        /// <summary>
        /// Perform shutdown tasks such as stopping the timers.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
            impl.StopScheduledTasks();
        }



        #region VSTO generated code
        ///
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        /// 
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        #endregion


    }
}
